<?php

class Globals{
	
	public static $db=null;
	
	function __construct(){
		
		
	}
	
	public static function connectdb(){
		try {
			$zend_config=Zend_Registry::get('zend_config');
			if($zend_config){
				self::$db=Zend_Db::factory($zend_config->database);
				self::$db->getProfiler()->setEnabled($zend_config->database->profiler->enabled);
				Zend_Db_Table_Abstract::setDefaultAdapter(self::$db);
	           // $db->getConnection();
	            try
	            {
	                self::$db->query( 'SET NAMES utf8' );
	                self::$db->query( 'SET CHARACTER SET utf8' );
	            } catch( Exception $e ){ }
			}
		}catch (Exception  $e){
			# write error
			var_dump($e);
			echo 'write error db 1';
			die();
		}
		
		if(!self::$db){
			# write error	
			echo 'write error db 2';
			die();
			
		}
	}
}

?>